﻿@inherits AdminCompontentBase
@page "/receiverGroups/receiverGroupManagement"

<PageTitle>@T("Permission.ReceiverGroupManagement")</PageTitle>
<AutoHeight AutoClass="mt-6">
    <HeaderContent>
        <SSearchPanel @bind-Value="@_queryParam.Filter" OnEnter="RefreshAsync" OnClearClick="HandleClearAsync" OnClick="()=> _createModal.OpenModalAsync()">
            <ChildContent>
                <DefaultTitle>@T("Title")</DefaultTitle>
            </ChildContent>
        </SSearchPanel>
    </HeaderContent>
    <AutoHeightContent>
        <MCard Class="full-height">
            <SDataTable Headers="GetHeaders()" Items="_entities.Result" TItem="ReceiverGroupDto" ItemsPerPage="_queryParam.PageSize" HideDefaultFooter FixedRight Class="d-flex full-height flex-column">
                <HeaderColContent Context="header">
                    <span class="text-btn">@header.Text</span>
                </HeaderColContent>
                <ItemColContent>
                    @switch (context.Header.Value)
                    {
                        case "Action":
                            <MButton Icon OnClick="async()=>await _editModal.OpenModalAsync(context.Item)">
                                <SIcon Small Color="emphasis2" Tooltip="@(T("Edit"))">mdi-pencil</SIcon>
                            </MButton>
                            break;
                        default:
                            <DefaultGenericColumnRender Value="@context.Value" Width="@context.Header.Width"></DefaultGenericColumnRender>
                            break;
                    }
                </ItemColContent>
                <FooterContent>
                    <SPagination Class="mt-3 mx-6 pb-6" Page="@_queryParam.Page" PageSize="@_queryParam.PageSize" Total="_entities.Total" PageChanged="HandlePageChanged" PageSizeChanged="HandlePageSizeChanged" />
                </FooterContent>
            </SDataTable>
        </MCard>
    </AutoHeightContent>
</AutoHeight>

<ReceiverGroupEditModal @ref="_editModal" OnOk="HandleOk" />
<ReceiverGroupCreateModal @ref="_createModal" OnOk="HandleOk" />

